package org.edu.modules.sxjy.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.edu.common.api.vo.Result;
import org.edu.modules.sxjy.entity.OssFile;
import org.edu.modules.sxjy.entity.VeApply;
import org.edu.modules.sxjy.entity.VeBaseStudent;
import org.edu.modules.sxjy.entity.VeBaseStudentInfo;
import org.edu.modules.sxjy.entity.VeClassTeacher;
import org.edu.modules.sxjy.entity.VeCommon;
import org.edu.modules.sxjy.entity.VeCompany;
import org.edu.modules.sxjy.entity.VeCompanyUser;
import org.edu.modules.sxjy.entity.VePost;
import org.edu.modules.sxjy.entity.VePractice;
import org.edu.modules.sxjy.entity.VeStudent;
import org.edu.modules.sxjy.feign.VeCommonClient;
import org.edu.modules.sxjy.mapper.VeApplyMapper;
import org.edu.modules.sxjy.mapper.VePracticeMapper;
import org.edu.modules.sxjy.oss.FileDTO;
import org.edu.modules.sxjy.redis.RedisUtils;
import org.edu.modules.sxjy.service.IOssFileService;
import org.edu.modules.sxjy.service.IVeApplyService;
import org.edu.modules.sxjy.service.IVeClassTeacharService;
import org.edu.modules.sxjy.service.IVeCompanyService;
import org.edu.modules.sxjy.service.IVeCompanyUserService;
import org.edu.modules.sxjy.service.IVePostService;
import org.edu.modules.sxjy.service.IVePracticeService;
import org.edu.modules.sxjy.service.IVeStudentService;
import org.edu.modules.sxjy.utils.DateUtils;
import org.edu.modules.sxjy.utils.PageResponseResult;
import org.edu.modules.sxjy.utils.PagingUtils;
import org.edu.modules.sxjy.vo.VeApplyStuInfoVo;
import org.edu.modules.sxjy.vo.VeApplysVo;
import org.edu.modules.sxjy.vo.VePracticeAddVo;
import org.edu.modules.sxjy.vo.VePracticeInfoVo;
import org.edu.modules.sxjy.vo.VePracticeReqVo;
import org.edu.modules.sxjy.vo.VePracticeSubmitTableVo;
import org.edu.modules.sxjy.vo.VePracticeUpdateVo;
import org.edu.modules.sxjy.vo.VePracticeVo;
import org.edu.modules.sxjy.vo.VePracticeVoXls;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class VePracticeServiceImpl
        extends ServiceImpl<VePracticeMapper, VePractice>
        implements IVePracticeService
{
    @Autowired
    private VePracticeMapper vePracticeMapper;
    @Autowired
    private VeApplyMapper veApplyMapper;
    @Autowired
    private IVePracticeService vePracticeService;
    @Autowired
    private IVeStudentService veStudentService;
    @Autowired
    private IVeCompanyService veCompanyService;
    @Autowired
    private IVeCompanyUserService veCompanyUserService;
    @Autowired
    private IVePostService vePostService;
    @Autowired
    private IOssFileService ossFileService;
    @Autowired
    private VeCommonClient veCommonClient;
    @Autowired
    private IVeClassTeacharService veClassTeacharService;
    @Autowired
    private IVeApplyService veApplyService;
    @Autowired
    private RedisUtils redisUtils;

    public List<VePracticeVo> selectAll(VePracticeVo vePracticeVo, Integer startLine, Integer pageSize, VeCommon veCommon)
    {
        List<VePracticeVo> vePracticeVoList = new ArrayList();
        VeCompanyUser veCompanyUser;
        if (veCommon.getUserType().contains("0"))
        {
            vePracticeVoList = this.vePracticeMapper.selectAll(vePracticeVo, startLine, pageSize, veCommon);
        }
        else if (veCommon.getUserType().equals("1"))
        {
            List<Integer> stuBjIdList = new ArrayList();

            List<VeClassTeacher> veClassTeacherList = this.veClassTeacharService.getBanjiIdByTeacherUserId(veCommon.getUserId());
            for (VeClassTeacher veClassTeacher : veClassTeacherList) {
                if ((veClassTeacher != null) && (!"".equals(veClassTeacher))) {
                    stuBjIdList.add(Integer.valueOf(veClassTeacher.getBjId()));
                }
            }
            veCommon.setStuBjId(stuBjIdList);
            if ((stuBjIdList != null) && (stuBjIdList.size() > 0)) {
                vePracticeVoList = this.vePracticeMapper.selectAll(vePracticeVo, startLine, pageSize, veCommon);
            } else {
                vePracticeVoList = new ArrayList();
            }
        }
        else if (veCommon.getUserType().equals("2"))
        {
            Object stuResult = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", veCommon.getUserId()).getResult();
            Map stuMap = (Map)stuResult;
            if (stuMap != null)
            {
                veCommon.setStuId(Integer.parseInt(stuMap.get("id").toString()));
                vePracticeVoList = this.vePracticeMapper.selectAll(vePracticeVo, startLine, pageSize, veCommon);
            }
        }
        else if ((veCommon.getUserType().equals("4")) || (veCommon.getUserType().equals("3")))
        {
            veCompanyUser = this.veCompanyUserService.getCpInfoByUserId(veCommon.getUserId());
            veCommon.setCpId(veCompanyUser.getCpId());

            vePracticeVoList = this.vePracticeMapper.selectAll(vePracticeVo, startLine, pageSize, veCommon);
        }
        if ((vePracticeVoList != null) && (vePracticeVoList.size() > 0)) {
            for (VePracticeVo practiceVo : vePracticeVoList)
            {
                VeApply veApply = this.vePracticeMapper.getStuApplyByStuUserId(practiceVo.getStuUserId());
                if ((veApply != null) && (!"".equals(veApply))) {
                    if (veApply.getType() == 2) {
                        practiceVo.setStuIsFocusApper(2);
                    } else if (veApply.getType() == 1) {
                        practiceVo.setStuIsFocusApper(1);
                    }
                }
                if (practiceVo.getStatus() == 1) {
                    practiceVo.setStatuss("已安排");
                } else if (practiceVo.getStatus() == 2) {
                    practiceVo.setStatuss("换岗");
                } else if (practiceVo.getStatus() == 3) {
                    practiceVo.setStatuss("已结束");
                } else {
                    practiceVo.setStatuss("已结束");
                }
                if ((practiceVo.getCteacherUserId() != null) && (!"".equals(practiceVo.getCteacherUserId())))
                {
                    String cpTeacherName = this.vePracticeMapper.getCpTeacherNameByUserId(practiceVo.getCteacherUserId());
                    practiceVo.setCteacherXm(cpTeacherName);
                }
                List<String> teacherNameByBjId = this.vePracticeMapper.getTeacherNameByBjId(practiceVo.getBjId());
                if ((teacherNameByBjId != null) && (!"".equals(teacherNameByBjId))) {
                    for (int i = 0; i < teacherNameByBjId.size(); i++) {
                        practiceVo.setTeacherName(teacherNameByBjId.toString().replace("[", "").replace("]", ""));
                    }
                }
                practiceVo.setCreateTime(DateUtils.getDateToString(Long.parseLong(practiceVo.getCreateTime())));
                practiceVo.setEndTime(DateUtils.getDateToString(Long.parseLong(practiceVo.getEndTime())));
                practiceVo.setStartTime(DateUtils.getDateToString(Long.parseLong(practiceVo.getStartTime())));
            }
        }
        return vePracticeVoList;
    }

    public int getSumPage(VePracticeVo vePracticeVo, VeCommon veCommon)
    {
        int pageNum = 0;
        if (veCommon.getUserType().contains("0"))
        {
            pageNum = this.vePracticeMapper.getSumPage(vePracticeVo, veCommon);
        }
        else if (veCommon.getUserType().equals("1"))
        {
            List<Integer> stuBjIdList = new ArrayList();

            List<VeClassTeacher> veClassTeacherList = this.veClassTeacharService.getBanjiIdByTeacherUserId(veCommon.getUserId());
            for (VeClassTeacher veClassTeacher : veClassTeacherList) {
                if ((veClassTeacher != null) && (!"".equals(veClassTeacher))) {
                    stuBjIdList.add(Integer.valueOf(veClassTeacher.getBjId()));
                }
            }
            veCommon.setStuBjId(stuBjIdList);
            if ((stuBjIdList != null) && (stuBjIdList.size() > 0)) {
                pageNum = this.vePracticeMapper.getSumPage(vePracticeVo, veCommon);
            } else {
                pageNum = 0;
            }
        }
        else if (veCommon.getUserType().equals("2"))
        {
            Object stuResult = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", veCommon.getUserId()).getResult();
            Map stuMap = (Map)stuResult;
            if (stuMap != null)
            {
                veCommon.setStuId(Integer.parseInt(stuMap.get("id").toString()));
                pageNum = this.vePracticeMapper.getSumPage(vePracticeVo, veCommon);
            }
        }
        else if ((veCommon.getUserType().equals("4")) || (veCommon.getUserType().equals("3")))
        {
            VeCompanyUser veCompanyUser = this.veCompanyUserService.getCpInfoByUserId(veCommon.getUserId());
            veCommon.setCpId(veCompanyUser.getCpId());

            pageNum = this.vePracticeMapper.getSumPage(vePracticeVo, veCommon);
        }
        return pageNum;
    }

    public List<VePracticeVoXls> exportXls(VeCommon veCommon)
    {
        List<VePracticeVo> vePracticeVoList = new ArrayList();
        Map stuMap;
        if (veCommon.getUserType().contains("0"))
        {
            vePracticeVoList = this.vePracticeMapper.exportXls(veCommon);
        }
        else if (veCommon.getUserType().equals("1"))
        {
            List<Integer> stuBjIdList = new ArrayList();

            List<VeClassTeacher> veClassTeacherList = this.veClassTeacharService.getBanjiIdByTeacherUserId(veCommon.getUserId());
            for (VeClassTeacher veClassTeacher : veClassTeacherList) {
                if ((veClassTeacher != null) && (!"".equals(veClassTeacher))) {
                    stuBjIdList.add(Integer.valueOf(veClassTeacher.getBjId()));
                }
            }
            veCommon.setStuBjId(stuBjIdList);
            if ((stuBjIdList != null) && (stuBjIdList.size() > 0)) {
                vePracticeVoList = this.vePracticeMapper.exportXls(veCommon);
            } else {
                vePracticeVoList = new ArrayList();
            }
        }
        else if (veCommon.getUserType().equals("2"))
        {
            Object stuResult = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", veCommon.getUserId()).getResult();
            stuMap = (Map)stuResult;
            if (stuMap != null)
            {
                veCommon.setStuId(Integer.parseInt(stuMap.get("id").toString()));
                vePracticeVoList = this.vePracticeMapper.exportXls(veCommon);
            }
        }
        else if ((veCommon.getUserType().equals("4")) || (veCommon.getUserType().equals("3")))
        {
            VeCompanyUser veCompanyUser = this.veCompanyUserService.getCpInfoByUserId(veCommon.getUserId());
            veCommon.setCpId(veCompanyUser.getCpId());

            vePracticeVoList = this.vePracticeMapper.exportXls(veCommon);
        }
        List<VePracticeVoXls> vePracticeVoXlsList = new ArrayList();
        for (VePracticeVo vePracticeVo : vePracticeVoList)
        {
            VePracticeVoXls vePracticeVoXls = new VePracticeVoXls();

            vePracticeVoXls.setXh(vePracticeVo.getXh());

            vePracticeVoXls.setXm(vePracticeVo.getXm());

            vePracticeVoXls.setCpName(vePracticeVo.getCpName());

            vePracticeVoXls.setStartTime(DateUtils.getDateToString(Long.parseLong(vePracticeVo.getStartTime())));

            vePracticeVoXls.setEndTime(DateUtils.getDateToString(Long.parseLong(vePracticeVo.getEndTime())));

            int isPro = ((VePractice)this.vePracticeService.getById(Integer.valueOf(vePracticeVo.getId()))).getIsPro();
            if (isPro == 1) {
                vePracticeVoXls.setIsPro("是");
            } else if (isPro == 0) {
                vePracticeVoXls.setIsPro("否");
            }
            int payment = ((VePractice)this.vePracticeService.getById(Integer.valueOf(vePracticeVo.getId()))).getPayment();
            if (payment != 0) {
                vePracticeVoXls.setPayment(payment);
            }
            vePracticeVoXls.setPostName(vePracticeVo.getPostName());

            String address = ((VePractice)this.vePracticeService.getById(Integer.valueOf(vePracticeVo.getId()))).getAddress();
            if ((address != null) && (!"".equals(address))) {
                vePracticeVoXls.setAddress(address);
            }
            vePracticeVoXlsList.add(vePracticeVoXls);
        }
        return vePracticeVoXlsList;
    }

    public boolean setExcel(VePracticeVoXls vePracticeVoXls)
    {
        VePractice vePractice = new VePractice();

        vePractice.setXm(vePracticeVoXls.getXm());

        vePractice.setXh(vePracticeVoXls.getXh());

        vePractice.setCpName(vePracticeVoXls.getCpName());

        VeCompany veCompany = this.vePracticeMapper.getCpNameId(vePracticeVoXls.getCpName());
        if ((veCompany == null) || ("".equals(veCompany))) {
            return false;
        }
        vePractice.setCpId(veCompany.getId());

        vePractice.setPostName(vePracticeVoXls.getPostName());

        VePost vePost = this.vePracticeMapper.getPostNameId(vePracticeVoXls.getPostName());
        if ((vePost == null) || ("".equals(vePost))) {
            return false;
        }
        vePractice.setPostId(vePost.getId());

        vePractice.setStartTime(DateUtils.getStringToDate(vePracticeVoXls.getStartTime()));

        vePractice.setEndTime(DateUtils.getStringToDate(vePracticeVoXls.getEndTime()));
        if (vePracticeVoXls.getIsPro().equals("否")) {
            vePractice.setIsPro(0);
        } else if ((vePracticeVoXls.getIsPro().equals("是")) && (vePracticeVoXls.getIsPro() == null)) {
            vePractice.setIsPro(1);
        }
        vePractice.setPayment(vePracticeVoXls.getPayment());

        vePractice.setAddress(vePracticeVoXls.getAddress());

        VeStudent veStudent = this.veStudentService.getListByXh(vePracticeVoXls.getXh());
        if ((veStudent == null) || ("".equals(veStudent))) {
            return false;
        }
        vePractice.setSfzh(veStudent.getSfzh());


        getStuInfoData(vePractice, veStudent);

        this.vePracticeService.save(vePractice);


        List<VePractice> list = null;
        QueryWrapper queryWrapper = new QueryWrapper();
        list = this.vePracticeService.list(queryWrapper);
        this.redisUtils.set("vePracticesList", list);


        return true;
    }

    private void getStuInfoData(VePractice vePractice, VeStudent veStudent)
    {
        if (veStudent != null)
        {
            vePractice.setFalId(veStudent.getFalId());

            vePractice.setSpecId(veStudent.getSpecId());

            vePractice.setGradeId(veStudent.getGradeId());

            vePractice.setBjId(veStudent.getBjId());

            vePractice.setUpdateTime(veStudent.getUpdateTime());

            vePractice.setStatus(1);

            vePractice.setStuUserId(veStudent.getId());

            vePractice.setSfzh(veStudent.getSfzh());

            vePractice.setTerminalId(1);

            vePractice.setCreateTime(veStudent.getCreateTime());
        }
    }

    public void add(VePracticeAddVo vePracticeAddVo)
    {
        VePractice vePractice = new VePractice();


        Object stuResult = this.veCommonClient.getStudentById("09d5e1e7f9b049008eee645c783a1d67", vePracticeAddVo.getStuUserId()).getResult();
        Map stuMap = (Map)stuResult;

        String s = JSON.toJSONString(stuMap);
        VeStudent stuUserId = (VeStudent)JSON.parseObject(s, VeStudent.class);


        vePractice.setApplyId(vePracticeAddVo.getApplyId());


        BeanUtils.copyProperties(vePracticeAddVo, vePractice);

        getStuInfoData(vePractice, stuUserId);

        vePractice.setXm(stuUserId.getXm());

        vePractice.setXh(stuUserId.getXh());

        vePractice.setCreateTime(System.currentTimeMillis());

        vePractice.setUpdateTime(System.currentTimeMillis());

        vePractice.setStartTime(DateUtils.getStringToDate(vePracticeAddVo.getStartTime()));

        vePractice.setEndTime(DateUtils.getStringToDate(vePracticeAddVo.getEndTime()));
        if (vePractice.getEndTime() < System.currentTimeMillis()) {
            vePractice.setStatus(3);
        }
        String cpNameById = this.veCompanyService.getCpNameById(vePracticeAddVo.getCpId());
        if ((cpNameById != null) && (!"".equals(cpNameById))) {
            vePractice.setCpName(cpNameById);
        }
        vePractice.setPostName(this.vePostService.getPostNameById(vePracticeAddVo.getPostId()));


        List<VeCompanyUser> cteacherUserId = this.vePracticeMapper.getCpRealNameByCpId(vePracticeAddVo.getCpId(), vePracticeAddVo.getPostId());
        if (cteacherUserId.size() != 0) {
            vePractice.setCteacherUserId(((VeCompanyUser)cteacherUserId.get(0)).getUserId());
        }
        this.vePracticeService.save(vePractice);

        List<VePractice> list = null;
        QueryWrapper queryWrapper = new QueryWrapper();
        list = this.vePracticeService.list(queryWrapper);
        this.redisUtils.set("vePracticesList", list);
    }

    public VePracticeUpdateVo updateEcho(int id)
    {
        VePracticeUpdateVo vePracticeUpdateVo = new VePracticeUpdateVo();

        VePractice vePractice = (VePractice)this.vePracticeService.getById(Integer.valueOf(id));



        vePracticeUpdateVo.setId(vePractice.getId());

        vePracticeUpdateVo.setStartTime(DateUtils.getDateToString(vePractice.getStartTime()));

        vePracticeUpdateVo.setEndTime(DateUtils.getDateToString(vePractice.getEndTime()));

        vePracticeUpdateVo.setPayment(vePractice.getPayment());

        vePracticeUpdateVo.setAddress(vePractice.getAddress());

        vePracticeUpdateVo.setCteacherUserId(vePractice.getCteacherUserId());

        List<VeCompanyUser> veCompanyUserList = this.veCompanyUserService.list();
        for (VeCompanyUser veCompanyUser : veCompanyUserList) {
            if (veCompanyUser.getUserId().equals(vePractice.getCteacherUserId())) {
                vePracticeUpdateVo.setCteacherUser(veCompanyUser.getRealName());
            }
        }
        vePracticeUpdateVo.setIsPro(vePractice.getIsPro());

        vePracticeUpdateVo.setTask(vePractice.getTask());

        VeStudent veStudent = (VeStudent)this.veStudentService.getById(Integer.valueOf(vePractice.getStuUserId()));
        if ((veStudent != null) && (!"".equals(veStudent)))
        {
            vePracticeUpdateVo.setXh(veStudent.getXh());

            vePracticeUpdateVo.setXm(veStudent.getXm());

            vePracticeUpdateVo.setSpecId(veStudent.getSpecId());
            String specName = this.vePracticeMapper.getSpecNameById(veStudent.getSpecId());
            if ((specName != null) && (!"".equals(specName))) {
                vePracticeUpdateVo.setSpec(specName);
            }
            vePracticeUpdateVo.setBjId(veStudent.getBjId());
            String bjName = this.vePracticeMapper.getBjNameById(veStudent.getBjId());
            if ((bjName != null) && (!"".equals(bjName))) {
                vePracticeUpdateVo.setBjName(bjName);
            }
        }
        Result<?> studentInfoById = this.veCommonClient.getStudentInfoById("09d5e1e7f9b049008eee645c783a1d67", vePractice.getStuUserId());
        if (studentInfoById.getCode().intValue() == 200)
        {
            Object stuInfoResult = studentInfoById.getResult();
            Map stuInfoMap = (Map)stuInfoResult;
            String s = JSON.toJSONString(stuInfoMap);
            VeBaseStudentInfo veBaseStudentInfo = (VeBaseStudentInfo)JSON.parseObject(s, VeBaseStudentInfo.class);
            if ((veBaseStudentInfo != null) && (!"".equals(veBaseStudentInfo)))
            {
                if (veBaseStudentInfo.getXslxdh() != null) {
                    vePracticeUpdateVo.setXslxdh(veBaseStudentInfo.getXslxdh());
                }
                if (veBaseStudentInfo.getJstxh() != null) {
                    vePracticeUpdateVo.setJstxh(veBaseStudentInfo.getJstxh());
                }
                if (veBaseStudentInfo.getJtdz() != null) {
                    vePracticeUpdateVo.setJtdz(veBaseStudentInfo.getJtdz());
                }
                if (veBaseStudentInfo.getJtlxdh() != null) {
                    vePracticeUpdateVo.setJtlxdh(veBaseStudentInfo.getJtlxdh());
                }
            }
        }
        VePost vePost = (VePost)this.vePostService.getById(Integer.valueOf(vePractice.getPostId()));
        if ((vePost != null) && (!"".equals(vePost)) &&
                (((VePost)this.vePostService.getById(Integer.valueOf(vePractice.getPostId()))).getPostName() != null)) {
            vePracticeUpdateVo.setPostName(((VePost)this.vePostService.getById(Integer.valueOf(vePractice.getPostId()))).getPostName());
        }
        VeCompany veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(vePractice.getCpId()));
        if ((veCompany != null) && (!"".equals(veCompany)))
        {
            vePracticeUpdateVo.setName(veCompany.getName());
            if (veCompany.getLinkman() != null) {
                vePracticeUpdateVo.setLinkman(veCompany.getLinkman());
            }
            if (veCompany.getTel() != null) {
                vePracticeUpdateVo.setTel(veCompany.getTel());
            }
        }
        return vePracticeUpdateVo;
    }

    public VePracticeInfoVo getOneInfo(int id)
    {
        VePracticeInfoVo vePracticeInfoVo = new VePracticeInfoVo();
        VePractice vePractice = (VePractice)this.vePracticeService.getById(Integer.valueOf(id));

        BeanUtils.copyProperties(vePractice, vePracticeInfoVo);


        VeBaseStudent veBaseStudent = new VeBaseStudent();
        Result<?> stuResult = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", vePractice.getXh());
        if (stuResult.getCode().equals(Integer.valueOf(200)))
        {
            Object result = stuResult.getResult();
            Map stuMap = (Map)result;
            if ((stuMap != null) && (!"".equals(stuMap)))
            {
                String s = JSON.toJSONString(stuMap);
                veBaseStudent = (VeBaseStudent)JSON.parseObject(s, VeBaseStudent.class);
            }
        }
        if ((veBaseStudent == null) || ("".equals(veBaseStudent))) {
            return null;
        }
        Result<?> bjResult = this.veCommonClient.queryBanJiById("09d5e1e7f9b049008eee645c783a1d67", veBaseStudent.getBjId());
        if (bjResult.getCode().equals(Integer.valueOf(200)))
        {
            Object result = bjResult.getResult();
            Map bjMap = (Map)result;
            if (bjMap != null) {
                vePracticeInfoVo.setBj(bjMap.get("xzbmc").toString());
            }
        }
        Result<?> specResult = this.veCommonClient.querySpecialtyById("09d5e1e7f9b049008eee645c783a1d67", veBaseStudent.getSpecId());
        if (specResult.getCode().equals(Integer.valueOf(200)))
        {
            Object result = specResult.getResult();
            Map specMap = (Map)result;
            if (specMap != null) {
                vePracticeInfoVo.setSpec(specMap.get("zymc").toString());
            }
        }
        VeBaseStudentInfo veBaseStudentInfo = new VeBaseStudentInfo();
        Result<?> stuInfoResult = this.veCommonClient.getStudentInfoByUserId("09d5e1e7f9b049008eee645c783a1d67", vePractice.getXh());
        if (stuInfoResult.getCode().equals(Integer.valueOf(200)))
        {
            Object result = stuInfoResult.getResult();
            Map stuMap = (Map)result;
            if ((stuMap != null) && (!"".equals(stuMap)))
            {
                String s = JSON.toJSONString(stuMap);
                veBaseStudentInfo = (VeBaseStudentInfo)JSON.parseObject(s, VeBaseStudentInfo.class);
            }
        }
        if ((veBaseStudentInfo == null) || ("".equals(veBaseStudentInfo))) {
            return null;
        }
        vePracticeInfoVo.setXslxdh(veBaseStudentInfo.getXslxdh());

        vePracticeInfoVo.setJstxh(veBaseStudentInfo.getJstxh());

        vePracticeInfoVo.setJtdz(veBaseStudentInfo.getJtdz());

        vePracticeInfoVo.setJtlxdh(veBaseStudentInfo.getJtlxdh());

        VeCompany veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(vePractice.getCpId()));
        if (veCompany != null)
        {
            if (veCompany.getLinkman() != null) {
                vePracticeInfoVo.setLinkman(veCompany.getLinkman());
            }
            if (veCompany.getTel() != null) {
                vePracticeInfoVo.setTel(veCompany.getTel());
            }
        }
        if ((vePractice.getCteacherUserId() != null) && (!"".equals(vePractice.getCteacherUserId())))
        {
            String cpTeacherNameByUserId = this.vePracticeMapper.getCpTeacherNameByUserId(vePractice.getCteacherUserId());
            if ((cpTeacherNameByUserId != null) && (!"".equals(cpTeacherNameByUserId))) {
                vePracticeInfoVo.setCteacherUser(cpTeacherNameByUserId);
            }
        }
        List<String> teacherNameByBjId = this.vePracticeMapper.getTeacherNameByBjId(veBaseStudent.getBjId().intValue());
        if ((teacherNameByBjId != null) && (!"".equals(teacherNameByBjId))) {
            for (int i = 0; i < teacherNameByBjId.size(); i++) {
                vePracticeInfoVo.setXxzdjs(teacherNameByBjId.toString().replace("[", "").replace("]", ""));
            }
        }
        vePracticeInfoVo.setStartTime(DateUtils.getDateToString(vePractice.getStartTime()));

        vePracticeInfoVo.setEndTime(DateUtils.getDateToString(vePractice.getEndTime()));
        if (vePractice.getCreateTime() != 0L) {
            vePracticeInfoVo.setRegs("已提交");
        } else {
            vePracticeInfoVo.setRegs("暂未提交");
        }
        if (vePracticeInfoVo.getStatus() == 1) {
            vePracticeInfoVo.setStatuss("已安排");
        } else if (vePracticeInfoVo.getStatus() == 2) {
            vePracticeInfoVo.setStatuss("换岗");
        } else if (vePracticeInfoVo.getStatus() == 3) {
            vePracticeInfoVo.setStatuss("已结束");
        }
        return vePracticeInfoVo;
    }

    public VePracticeInfoVo getStuOneInfo(String userId)
    {
        VePracticeInfoVo vePracticeInfoVos = new VePracticeInfoVo();

        Object stuResult = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", userId).getResult();
        Map stuMaps = (Map)stuResult;
        int stuId = Integer.parseInt(stuMaps.get("id").toString());
        int stuBjId = Integer.parseInt(stuMaps.get("bjId").toString());
        if (stuId != 0)
        {
            List<VeApply> veApplyList = this.veApplyMapper.getApplyConntByStuId(stuId);
            if (veApplyList.size() == 1)
            {
                VePracticeInfoVo vePracticeInfoVo = new VePracticeInfoVo();


                Object studentInfoResult = this.veCommonClient.getStudentInfoByUserId("09d5e1e7f9b049008eee645c783a1d67", userId).getResult();
                Map stuInfoMap = (Map)studentInfoResult;
                if ((stuInfoMap != null) && (stuInfoMap.size() > 0))
                {
                    vePracticeInfoVo.setXslxdh(stuInfoMap.get("xslxdh").toString());

                    vePracticeInfoVo.setJstxh(stuInfoMap.get("jstxh").toString());

                    vePracticeInfoVo.setJtdz(stuInfoMap.get("jtdz").toString());

                    vePracticeInfoVo.setJtlxdh(stuInfoMap.get("jtlxdh").toString());
                }
                Result<?> result = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", userId);
                Object studentResult = result.getResult();
                Map stuMap = (Map)studentResult;
                if ((stuMap != null) && (stuMap.size() > 0))
                {
                    vePracticeInfoVo.setXh(stuMap.get("xh").toString());

                    vePracticeInfoVo.setXm(stuMap.get("xm").toString());
                }
                if (stuBjId != 0)
                {
                    List<String> teacherNameList = this.vePracticeMapper.getTeacherNameByBjId(stuBjId);
                    if ((teacherNameList != null) && (teacherNameList.size() > 0)) {
                        vePracticeInfoVo.setXxzdjs((String)teacherNameList.get(0));
                    }
                }
                if (stuMap != null)
                {
                    Object bjIdResult = this.veCommonClient.queryBanJiById("09d5e1e7f9b049008eee645c783a1d67", Integer.valueOf(Integer.parseInt(stuMap.get("bjId").toString()))).getResult();
                    Map bjIdMap = (Map)bjIdResult;
                    if ((bjIdMap != null) && (bjIdMap.size() > 0)) {
                        vePracticeInfoVo.setBj(bjIdMap.get("xzbmc").toString());
                    }
                }
                if (stuMap != null)
                {
                    Object specIdResult = this.veCommonClient.querySpecialtyById("09d5e1e7f9b049008eee645c783a1d67", Integer.valueOf(Integer.parseInt(stuMap.get("specId").toString()))).getResult();
                    Map specIdMap = (Map)specIdResult;
                    if ((specIdMap != null) && (specIdMap.size() > 0)) {
                        vePracticeInfoVo.setSpec(specIdMap.get("zymc").toString());
                    }
                }
                VeCompany veCompany = new VeCompany();

                VeApply veApply = this.vePracticeMapper.getCpInfoByUserId(Integer.parseInt(stuMap.get("id").toString()));
                if ((veApply != null) && (!"".equals(veApply)))
                {
                    veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(veApply.getCpId()));

                    vePracticeInfoVo.setCpId(veApply.getCpId());

                    vePracticeInfoVo.setCpName(veApply.getCpName());

                    vePracticeInfoVo.setPostName(veApply.getPostName());

                    vePracticeInfoVo.setStartTime(DateUtils.getDateToString(veApply.getStartTime()));

                    vePracticeInfoVo.setEndTime(DateUtils.getDateToString(veApply.getEndTime()));

                    List<VeCompanyUser> veCompanyUser = this.vePracticeMapper.getCpRealNameByCpId(veApply.getCpId(), veApply.getPostId());
                    if (veCompanyUser.size() != 0) {
                        vePracticeInfoVo.setCteacherUser(((VeCompanyUser)veCompanyUser.get(0)).getUserId());
                    }
                }
                if (veCompany != null)
                {
                    vePracticeInfoVo.setLinkman(veCompany.getLinkman());

                    vePracticeInfoVo.setTel(veCompany.getTel());
                }
                return vePracticeInfoVo;
            }
            VePracticeInfoVo vePracticeInfoVo = new VePracticeInfoVo();


            Object studentInfoResult = this.veCommonClient.getStudentInfoByUserId("09d5e1e7f9b049008eee645c783a1d67", userId).getResult();
            Map stuInfoMap = (Map)studentInfoResult;
            if ((stuInfoMap != null) && (stuInfoMap.size() > 0))
            {
                vePracticeInfoVo.setXslxdh(stuInfoMap.get("xslxdh").toString());

                vePracticeInfoVo.setJstxh(stuInfoMap.get("jstxh").toString());

                vePracticeInfoVo.setJtdz(stuInfoMap.get("jtdz").toString());

                vePracticeInfoVo.setJtlxdh(stuInfoMap.get("jtlxdh").toString());
            }
            Object studentResult = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", userId).getResult();
            Map stuMap = (Map)studentResult;
            if ((stuMap != null) && (stuMap.size() > 0))
            {
                vePracticeInfoVo.setXh(stuMap.get("xh").toString());

                vePracticeInfoVo.setXm(stuMap.get("xm").toString());
            }
            if (stuBjId != 0)
            {
                List<String> teacherNameList = this.vePracticeMapper.getTeacherNameByBjId(stuBjId);
                if ((teacherNameList != null) && (teacherNameList.size() > 0)) {
                    vePracticeInfoVo.setXxzdjs(teacherNameList.toString().replace("[", "").replace("]", ""));
                }
            }
            if (stuMap != null)
            {
                Object bjIdResult = this.veCommonClient.queryBanJiById("09d5e1e7f9b049008eee645c783a1d67", Integer.valueOf(Integer.parseInt(stuMap.get("bjId").toString()))).getResult();
                Map bjIdMap = (Map)bjIdResult;
                if ((bjIdMap != null) && (bjIdMap.size() > 0)) {
                    vePracticeInfoVo.setBj(bjIdMap.get("xzbmc").toString());
                }
            }
            if (stuMap != null)
            {
                Object specIdResult = this.veCommonClient.querySpecialtyById("09d5e1e7f9b049008eee645c783a1d67", Integer.valueOf(Integer.parseInt(stuMap.get("specId").toString()))).getResult();
                Map specIdMap = (Map)specIdResult;
                if ((specIdMap != null) && (specIdMap.size() > 0)) {
                    vePracticeInfoVo.setSpec(specIdMap.get("zymc").toString());
                }
            }
            VeCompany veCompany = new VeCompany();

            VeApply veApply = this.vePracticeMapper.getNewCpInfoByUserId(Integer.parseInt(stuMap.get("id").toString()));
            if ((veApply != null) && (!"".equals(veApply)))
            {
                veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(veApply.getCpId()));

                vePracticeInfoVo.setCpName(veApply.getCpName());

                vePracticeInfoVo.setPostName(veApply.getPostName());

                vePracticeInfoVo.setStartTime(DateUtils.getDateToString(veApply.getStartTime()));

                vePracticeInfoVo.setEndTime(DateUtils.getDateToString(veApply.getEndTime()));

                List<VeCompanyUser> veCompanyUser = this.vePracticeMapper.getCpRealNameByCpId(veApply.getCpId(), veApply.getPostId());
                if (veCompanyUser.size() != 0) {
                    vePracticeInfoVo.setCteacherUser(((VeCompanyUser)veCompanyUser.get(0)).getUserId());
                }
            }
            if (veCompany != null)
            {
                vePracticeInfoVo.setLinkman(veCompany.getLinkman());

                vePracticeInfoVo.setTel(veCompany.getTel());
            }
            return vePracticeInfoVo;
        }
        return vePracticeInfoVos;
    }

    public Result<?> getStuApplyInfo(int stuId)
    {
        VeApply veApply = this.vePracticeMapper.getStuApplyInfo(stuId);
        if ((veApply != null) && (!"".equals(veApply)))
        {
            VeApplysVo veApplysVo = new VeApplysVo();
            BeanUtils.copyProperties(veApply, veApplysVo);
            veApplysVo.setStartTime(DateUtils.getDateToString(veApply.getStartTime()));
            veApplysVo.setEndTime(DateUtils.getDateToString(veApply.getEndTime()));





            return Result.OK(veApplysVo);
        }
        return Result.OK();
    }

    public List<VeStudent> getStuName(String name)
    {
        return this.vePracticeMapper.getStuName(name);
    }

    public List<VeCompany> getCpName(String name)
    {
        return this.vePracticeMapper.getCpName(name);
    }

    public List<VePost> getPostName(String name)
    {
        return this.vePracticeMapper.getPostName(name);
    }

    public void updates(VePracticeUpdateVo vePracticeUpdateVo)
    {
        VePractice vePractices = (VePractice)this.vePracticeService.getById(Integer.valueOf(vePracticeUpdateVo.getId()));
        if ((vePractices != null) && (!"".equals(vePractices)))
        {
            vePractices.setStartTime(DateUtils.getStringToDate(vePracticeUpdateVo.getStartTime()));


            vePractices.setEndTime(DateUtils.getStringToDate(vePracticeUpdateVo.getEndTime()));
            if (vePractices.getEndTime() < System.currentTimeMillis())
            {
                vePractices.setStatus(3);
            }
            else if (vePractices.getEndTime() > System.currentTimeMillis())
            {
                List<VeApply> veApplyList = this.vePracticeMapper.getApplyByStuId(vePractices.getStuUserId());
                if ((veApplyList != null) && (veApplyList.size() > 0)) {
                    vePractices.setStatus(2);
                } else {
                    vePractices.setStatus(1);
                }
            }
            vePractices.setPayment(vePracticeUpdateVo.getPayment());

            vePractices.setAddress(vePracticeUpdateVo.getAddress());

            vePractices.setIsPro(vePracticeUpdateVo.getIsPro());

            vePractices.setTask(vePracticeUpdateVo.getTask());
        }
        this.vePracticeMapper.updatePractices(vePractices);

        List<VePractice> list = null;
        QueryWrapper queryWrapper = new QueryWrapper();
        list = this.vePracticeService.list(queryWrapper);
        this.redisUtils.set("vePracticesList", list);
    }

    public void addRegister(VePracticeReqVo vePracticeReqVo)
    {
        VePractice vePractices = new VePractice();

        Object stuResults = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", vePracticeReqVo.getUserId()).getResult();
        Map stuMaps = (Map)stuResults;
        if (stuMaps.get("id") != null) {
            vePractices = this.vePracticeMapper.getPracticeByUserId(Integer.parseInt(stuMaps.get("id").toString()));
        }
        if (vePractices == null)
        {
            Object stuResult = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", vePracticeReqVo.getUserId()).getResult();
            Map stuMap = (Map)stuResult;
            String s = JSON.toJSONString(stuMap);
            VeStudent veStudent = (VeStudent)JSON.parseObject(s, VeStudent.class);



            VeApply veApply = this.veApplyMapper.getByIds(veStudent.getId());



            VePractice vePractice = new VePractice();
            if ((veApply != null) && (!"".equals(veApply)))
            {
                vePractice.setIsPro(vePracticeReqVo.getIsPro());

                vePractice.setPayment(vePracticeReqVo.getPayment());


                vePractice.setTask(vePracticeReqVo.getTask());



                vePractice.setApplyId(veApply.getId());

                vePractice.setPostId(veApply.getPostId());

                vePractice.setPostName(veApply.getPostName());

                vePractice.setFalId(veStudent.getFalId());

                vePractice.setSpecId(veStudent.getSpecId());

                vePractice.setGradeId(veStudent.getGradeId());

                vePractice.setBjId(veStudent.getBjId());

                vePractice.setCpId(veApply.getCpId());

                vePractice.setCpName(veApply.getCpName());

                vePractice.setStartTime(veApply.getStartTime());

                vePractice.setEndTime(veApply.getEndTime());





                List<VeCompanyUser> veCompanyUser = this.vePracticeMapper.getCpRealNameByCpId(veApply.getCpId(), veApply.getPostId());
                if (veCompanyUser.size() != 0) {
                    vePractice.setCteacherUserId(((VeCompanyUser)veCompanyUser.get(0)).getUserId());
                }
                vePractice.setStatus(1);

                vePractice.setStuUserId(veStudent.getId());

                vePractice.setSfzh(veStudent.getSfzh());

                vePractice.setXh(veStudent.getXh());

                vePractice.setXm(veStudent.getXm());

                vePractice.setTerminalId(1);

                vePractice.setCreateTime(System.currentTimeMillis());

                vePractice.setUpdateTime(System.currentTimeMillis());

                vePractice.setRegTime(System.currentTimeMillis());

                vePractice.setReason("");

                vePractice.setAddress(veApply.getAddress());
            }
            if ((vePracticeReqVo.getFileDTO() != null) && (!"".equals(vePracticeReqVo.getFileDTO())))
            {
                String webUrl = vePracticeReqVo.getFileDTO().getWebUrl();

                OssFile ossFile = new OssFile();

                ossFile.setUrl(webUrl);

                ossFile.setFileName(vePracticeReqVo.getFileDTO().getOldFileName());

                ossFile.setCreateBy("创建人登录名称");

                ossFile.setCreateTime(new Date());

                ossFile.setUpdateBy("更新人登录名称");

                ossFile.setUpdateTime(new Date());

                this.ossFileService.save(ossFile);


                List<String> ossFileIdList = this.vePracticeMapper.getOssFileIdByUrl(ossFile.getUrl());
                if ((ossFileIdList != null) && (ossFileIdList.size() > 0)) {
                    vePractice.setFileId((String)ossFileIdList.get(ossFileIdList.size() - 1));
                }
            }
            this.vePracticeService.save(vePractice);


            List<VePractice> list = null;
            QueryWrapper queryWrapper = new QueryWrapper();
            list = this.vePracticeService.list(queryWrapper);
            this.redisUtils.set("vePracticesList", list);
        }
        else
        {
            Object stuResult = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", vePracticeReqVo.getUserId()).getResult();
            Map stuMap = (Map)stuResult;
            String s = JSON.toJSONString(stuMap);
            VeStudent veStudent = (VeStudent)JSON.parseObject(s, VeStudent.class);



            VeApply veApply = this.veApplyMapper.getByIds(veStudent.getId());



            VePractice vePractice = new VePractice();
            if ((veApply != null) && (!"".equals(veApply)))
            {
                vePractice.setId(vePractices.getId());

                vePractice.setIsPro(vePracticeReqVo.getIsPro());

                vePractice.setPayment(vePracticeReqVo.getPayment());


                vePractice.setTask(vePracticeReqVo.getTask());



                vePractice.setApplyId(veApply.getId());

                vePractice.setPostId(veApply.getPostId());

                vePractice.setPostName(veApply.getPostName());

                vePractice.setFalId(veStudent.getFalId());

                vePractice.setSpecId(veStudent.getSpecId());

                vePractice.setGradeId(veStudent.getGradeId());

                vePractice.setBjId(veStudent.getBjId());

                vePractice.setCpId(veApply.getCpId());

                vePractice.setCpName(veApply.getCpName());

                vePractice.setStartTime(veApply.getStartTime());

                vePractice.setEndTime(veApply.getEndTime());

                List<VeCompanyUser> veCompanyUser = this.vePracticeMapper.getCpRealNameByCpId(veApply.getCpId(), veApply.getPostId());
                if (veCompanyUser.size() != 0) {
                    vePractice.setCteacherUserId(((VeCompanyUser)veCompanyUser.get(0)).getUserId());
                }
                vePractice.setStatus(1);

                vePractice.setStuUserId(veStudent.getId());

                vePractice.setSfzh(veStudent.getSfzh());

                vePractice.setXh(veStudent.getXh());

                vePractice.setXm(veStudent.getXm());

                vePractice.setTerminalId(1);

                vePractice.setCreateTime(System.currentTimeMillis());

                vePractice.setUpdateTime(System.currentTimeMillis());

                vePractice.setRegTime(System.currentTimeMillis());

                vePractice.setReason("");

                vePractice.setAddress(veApply.getAddress());
            }
            if ((vePracticeReqVo.getFileDTO() != null) && (!"".equals(vePracticeReqVo.getFileDTO())))
            {
                String webUrl = vePracticeReqVo.getFileDTO().getWebUrl();

                OssFile ossFile = new OssFile();

                ossFile.setUrl(webUrl);

                ossFile.setFileName(vePracticeReqVo.getFileDTO().getOldFileName());

                ossFile.setCreateBy("创建人登录名称");

                ossFile.setCreateTime(new Date());

                ossFile.setUpdateBy("更新人登录名称");

                ossFile.setUpdateTime(new Date());

                this.ossFileService.save(ossFile);


                List<String> ossFileIdList = this.vePracticeMapper.getOssFileIdByUrl(ossFile.getUrl());
                if ((ossFileIdList != null) && (ossFileIdList.size() > 0)) {
                    vePractice.setFileId((String)ossFileIdList.get(ossFileIdList.size() - 1));
                }
            }
            this.vePracticeMapper.updatePractices(vePractice);

            List<VePractice> list = null;
            QueryWrapper queryWrapper = new QueryWrapper();
            list = this.vePracticeService.list(queryWrapper);
            this.redisUtils.set("vePracticesList", list);
        }
    }

    public VePractice getByIds(int stuId)
    {
        return this.vePracticeMapper.getByIds(stuId);
    }

    public Result<?> stuIsPracticeByStuId(int stuId)
    {
        Object stuResult = this.veCommonClient.getStudentById("09d5e1e7f9b049008eee645c783a1d67", stuId).getResult();
        if (stuResult != null)
        {
            Map stuResultMap = (Map)stuResult;
            String s = JSON.toJSONString(stuResultMap);
            VeBaseStudent veBaseStudent = (VeBaseStudent)JSON.parseObject(s, VeBaseStudent.class);
            if ((veBaseStudent != null) && (!"".equals(veBaseStudent)))
            {
                VePractice vePractice = this.vePracticeMapper.stuIsPracticeByStuId(veBaseStudent.getId().intValue());
                if ((vePractice != null) && (!"".equals(vePractice))) {
                    return Result.error("该学生已经安排，请直接修改信息");
                }
                return Result.OK(veBaseStudent);
            }
        }
        return Result.error("信息有误");
    }

    public PageResponseResult getNoPracticeStuList(String stuName, Integer pageNo, Integer pageSize)
    {
        List<VeApplyStuInfoVo> veApplyStuInfoVoList = new ArrayList();
        List<VeApply> veApplyList = this.veApplyService.list();
        List<VePractice> practiceList = this.vePracticeService.list();
        Result<?> studentListStudent = this.veCommonClient.getStudentList("09d5e1e7f9b049008eee645c783a1d67", stuName);
        Object stuReuslt;
        if (studentListStudent.getCode().equals(Integer.valueOf(200)))
        {
            stuReuslt = studentListStudent.getResult();
            if (stuReuslt != null)
            {
                List<Object> stuResultList = (List)stuReuslt;
                for (Object o : stuResultList)
                {
                    String s = JSON.toJSONString(o);
                    VeBaseStudent veBaseStudent = (VeBaseStudent)JSON.parseObject(s, VeBaseStudent.class);
                    for (VeApply veApply : veApplyList) {
                        if ((veApply.getStatus() == 1) && (veApply.getStuUserId() == veBaseStudent.getId().intValue()))
                        {
                            VeApplyStuInfoVo veApplyStuInfoVo = new VeApplyStuInfoVo();

                            veApplyStuInfoVo.setStuId(veBaseStudent.getId().intValue());

                            veApplyStuInfoVo.setXm(veBaseStudent.getXm());

                            veApplyStuInfoVo.setXh(veBaseStudent.getXh());

                            veApplyStuInfoVo.setXbm(veBaseStudent.getXbm());

                            veApplyStuInfoVo.setSfzh(veBaseStudent.getSfzh());

                            veApplyStuInfoVo.setCpId(veApply.getCpId());

                            veApplyStuInfoVo.setPostId(veApply.getPostId());
                            if (veApply.getType() == 1) {
                                veApplyStuInfoVo.setIsStuApplyType(1);
                            } else if (veApply.getType() == 2) {
                                veApplyStuInfoVo.setIsStuApplyType(2);
                            } else {
                                veApplyStuInfoVo.setIsStuApplyType(0);
                            }
                            veApplyStuInfoVoList.add(veApplyStuInfoVo);
                        }
                    }
                }
            }
        }
        VeBaseStudent veBaseStudent;
        for (VePractice vePractice : practiceList) {
            for (int i = 0; i < veApplyStuInfoVoList.size(); i++) {
                if (vePractice.getStuUserId() == ((VeApplyStuInfoVo)veApplyStuInfoVoList.get(i)).getStuId()) {
                    veApplyStuInfoVoList.remove(i);
                }
            }
        }
        if ((veApplyStuInfoVoList != null) && (veApplyStuInfoVoList.size() > 0))
        {
            Map<String, Object> pageData = PagingUtils.getPageData(veApplyStuInfoVoList, pageNo, pageSize);
            List<VeApply> veApplyLists = (List)pageData.get("data");
            int totalPage = ((Integer)pageData.get("totalPage")).intValue();
            return new PageResponseResult(pageNo, totalPage, veApplyStuInfoVoList.size(), Result.OK(veApplyLists));
        }
        return new PageResponseResult(Integer.valueOf(1), 1, 0, Result.OK());
    }

    @Scheduled(cron="0 0 0 * * ?")
    public void execute()
    {
        boolean key = this.redisUtils.exists("vePracticesList");
        List<VePractice> list = null;
        if (key)
        {
            list = (List)this.redisUtils.get("vePracticesList");
        }
        else
        {
            QueryWrapper queryWrapper = new QueryWrapper();
            list = this.vePracticeService.list(queryWrapper);
            this.redisUtils.set("vePracticesList", list);
        }
        List<VePractice> vePracticesList = (List)this.redisUtils.get("vePracticesList");
        if ((vePracticesList != null) && (vePracticesList.size() > 0)) {
            for (VePractice vePractice : vePracticesList) {
                if ((vePractice.getStatus() != 3) &&
                        (vePractice.getEndTime() <= System.currentTimeMillis()))
                {
                    vePractice.setStatus(3);
                    this.vePracticeMapper.updatePractices(vePractice);

                    QueryWrapper queryWrapper = new QueryWrapper();
                    list = this.vePracticeService.list(queryWrapper);
                    this.redisUtils.set("vePracticesList", list);
                }
            }
        }
    }

    public Result<?> delete(String id)
    {
        int stuUserId = ((VePractice)this.vePracticeService.getById(id)).getStuUserId();
        if (stuUserId != 0)
        {
            this.vePracticeMapper.deleteNewApplyByStuUserId(stuUserId);

            this.vePracticeMapper.updateStuApplyByStuUserId(stuUserId);

            this.vePracticeMapper.deleteAttendanceByStuId(stuUserId);

            this.vePracticeMapper.deleteChangeByStuId(stuUserId);

            this.vePracticeMapper.deleteDynamicByStuId(stuUserId);

            this.vePracticeMapper.deleteLogByStuId(stuUserId);

            this.vePracticeMapper.deleteResultByStuId(stuUserId);

            this.vePracticeMapper.deleteSumupByStuId(stuUserId);

            this.vePracticeService.removeById(id);
        }
        List<VePractice> list = null;
        QueryWrapper queryWrapper = new QueryWrapper();
        list = this.vePracticeService.list(queryWrapper);
        this.redisUtils.set("vePracticesList", list);

        return Result.OK("删除成功");
    }

    public Result<?> deleeteBatch(String ids)
    {
        List<String> stringList = Arrays.asList(ids.split(","));
        for (String prcId : stringList)
        {
            int stuUserId = ((VePractice)this.vePracticeService.getById(prcId)).getStuUserId();
            if (stuUserId != 0)
            {
                this.vePracticeMapper.deleteNewApplyByStuUserId(stuUserId);

                this.vePracticeMapper.updateStuApplyByStuUserId(stuUserId);

                this.vePracticeMapper.deleteAttendanceByStuId(stuUserId);

                this.vePracticeMapper.deleteChangeByStuId(stuUserId);

                this.vePracticeMapper.deleteDynamicByStuId(stuUserId);

                this.vePracticeMapper.deleteLogByStuId(stuUserId);

                this.vePracticeMapper.deleteResultByStuId(stuUserId);

                this.vePracticeMapper.deleteSumupByStuId(stuUserId);

                this.vePracticeService.removeById(prcId);
            }
        }
        Object list = null;
        QueryWrapper queryWrapper = new QueryWrapper();
        list = this.vePracticeService.list(queryWrapper);
        this.redisUtils.set("vePracticesList", list);

        return Result.OK("批量删除成功");
    }

    public Result<?> stuSubmitTableEcho(String userId)
    {
        VePracticeSubmitTableVo vePracticeSubmitTableVo = new VePracticeSubmitTableVo();
        Result<?> result = this.veCommonClient.queryStudentById("09d5e1e7f9b049008eee645c783a1d67", userId);
        if (result.getCode().equals(Integer.valueOf(200)))
        {
            Object stuResult = result.getResult();
            String s = JSON.toJSONString(stuResult);
            VeBaseStudent veBaseStudent = (VeBaseStudent)JSON.parseObject(s, VeBaseStudent.class);
            if ((veBaseStudent != null) && (!"".equals(veBaseStudent)))
            {
                VePractice vePractice = this.vePracticeMapper.getPracticeByUserId(veBaseStudent.getId().intValue());
                if ((vePractice != null) && (!"".equals(vePractice)))
                {
                    vePracticeSubmitTableVo.setIsPro(vePractice.getIsPro());

                    vePracticeSubmitTableVo.setPayment(vePractice.getPayment());

                    vePracticeSubmitTableVo.setTask(vePractice.getTask());

                    OssFile ossFile = (OssFile)this.ossFileService.getById(vePractice.getFileId());
                    FileDTO fileDTO = new FileDTO();
                    if ((ossFile != null) && (!"".equals(ossFile)))
                    {
                        fileDTO.setWebUrl(ossFile.getUrl());
                        vePracticeSubmitTableVo.setFileDTO(fileDTO);
                    }
                    return Result.OK(vePracticeSubmitTableVo);
                }
            }
        }
        return Result.OK(vePracticeSubmitTableVo);
    }

    public List<VePractice> getPracticeListByCpId(Integer cpId)
    {
        return this.vePracticeMapper.getPracticeListByCpId(cpId);
    }

    public Result<?> getPracticeByStuUserId(int stuUserId)
    {
        VePractice vePractice = this.vePracticeMapper.getPracticeByStuUserId(stuUserId);

        VePracticeVo vePracticeVo = new VePracticeVo();

        BeanUtils.copyProperties(vePractice, vePracticeVo);


        vePracticeVo.setStartTime(DateUtils.getDateToString(vePractice.getStartTime()));


        vePracticeVo.setEndTime(DateUtils.getDateToString(vePractice.getEndTime()));
        if ((vePracticeVo != null) && (!"".equals(vePracticeVo))) {
            return Result.OK(vePracticeVo);
        }
        return Result.error("信息有误");
    }
}
